<%@ include file="/WEB-INF/views/commonJSTL.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<script type="text/javascript">
	$(document).ready(function(){	
		$('.numbersOnly').keyup(function () {
	        if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
	           this.value = this.value.replace(/[^0-9\.]/g, '');
	        }
	    });
		$('.percentage').keyup(function () {
	        if (this.value > 100)
	        	this.value = 100;
	        if (this.value < 0)
		    	this.value = 0;
	    });
		$('.calculate').keyup(function () {
			calculatePriceDialog($("#_unitsd").val(),$("#_unitPriced").val(),$("#_discountd").val());
	    });
	});
	function calculatePriceDialog(units,unitPrice,discount){		
		if(pack != null){
			$("#_unitPriced").val(unitPrice);
        	$("#_unitsd").val(units);	     
        	$("#_priceTotald").val(parseFloat(units*unitPrice).toFixed(1));
        	if(unitPrice != '')
        		$("#_priceTotalWithDiscountd").text(parseFloat(($("#_priceTotald").val())*((100-(discount))/100)).toFixed(1));
		}
	}
	
</script>
<c:set var="classTemp" value="form_align35" />
<div style="clear:both;" id="divShowFormItemSimple">
<form id="formDialogItemSimple">
	<input type="hidden" name="productId_" value="100"/>
	<fieldset>		
		<legend><b><fmt:message key="title.dataSale"/></b></legend>
		
		<div style="clear:both;">
			<c:set var="showUnitPrice" scope="page"><fmt:message key="show.form.unitPrice"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.unitPrice"/>:</label>
			<input type="text" name="_unitPriced" id="_unitPriced"  value="" class="required form_input_align numbersOnly calculate" title="${showUnitPrice}"/>&nbsp;&nbsp;<fmt:message key="title.sigleMoney"/>
		</div>	
		
		<div style="clear:both;">
			<c:set var="showUnits" scope="page"><fmt:message key="show.form.units"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.units"/>:</label>
			<input type="text" name="_unitsd" id="_unitsd"  value="" class="required form_input_align numberOnlyNumber calculate" title="${showUnits}"/>
		</div>
		
		<div style="clear:both;">
			<c:set var="showPriceTotal" scope="page"><fmt:message key="show.form.priceTotal"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.priceTotal"/>:</label>
			<input type="text" name="_priceTotald" id="_priceTotald"  value="" class="required form_input_align numbersOnly calculate" title="${showPriceTotal}"/>&nbsp;&nbsp;<fmt:message key="title.sigleMoney"/>
		</div>	
		<div style="clear:both;">
			<c:set var="showDiscount" scope="page"><fmt:message key="show.form.discount"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.discount"/>:</label>
			<input type="text" name="_discountd" id="_discountd" value="0" class="form_input_align numbersOnly percentage calculate" title="${showDiscount}"/> &nbsp;&nbsp;%
		</div>	
		<div style="clear:both;">
			<label class="${classTemp}"><fmt:message key="form.priceTotalEachDesc"/>:</label>
			<label ><div id="_priceTotalWithDiscountd"></div></label>
		</div>			
	</fieldset>	
</form>
</div>




